﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
using Microsoft.Practices.EnterpriseLibrary.Logging;

namespace Microsoft.IT.Crm.Utility.CrmSolutionManager
{
    public class EnterpriseLibLogger
    {
        public static void Log(string message)
        {
            Log(message, Component.Common, TraceEventType.Information);
        }

        public static void Log(string message, Component component)
        {
            Log(message, component, TraceEventType.Information);
        }

        public static void Log(string message, Component component, TraceEventType level)
        {
            LogEntry entry = new LogEntry();
            entry.Message = message;
            entry.Categories.Add(component.ToString());
            entry.Severity = level;
            Logger.Write(entry);
        }

        public static void Log(string message, Exception e, Component component, TraceEventType level)
        {
            LogEntry entry = new LogEntry();
            entry.Message = string.Format("{0}, Exception is: {1}", message, e.ToString());
            entry.Categories.Add(component.ToString());
            entry.Severity = level;
            Logger.Write(entry);
        }
    }
}